package com.fengli.task.entity;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 使用的是spring自带的校验
 * @Description:
 * @Author: fengli
 * @Date 4/20/19 10:12 AM
 */
@Entity
@Table(name = "user", schema = "task", catalog = "")
public class UserEntity implements Serializable {
    private String id;
    @Email(message = "邮箱格式错误")
    private String email;
    @NotBlank(message = "password不能为空")
    private String password;
    private String headPicture;
    private Boolean del = false;

    @Id
    @Column(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "email")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "password")
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "head_picture")
    public String getHeadPicture() {
        return headPicture;
    }

    public void setHeadPicture(String headPicture) {
        this.headPicture = headPicture;
    }

    @Basic
    @Column(name = "del")
    public boolean isDel() {
        return del;
    }

    public void setDel(boolean del) {
        this.del = del;
    }

    @Override
    public String toString() {
        return "UserEntity{" +
                "id='" + id + '\'' +
                ", email='" + email + '\'' +
                ", password='" + password + '\'' +
                ", headPicture='" + headPicture + '\'' +
                ", del=" + del +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserEntity that = (UserEntity) o;
        return del == that.del &&
                Objects.equals(id, that.id) &&
                Objects.equals(email, that.email) &&
                Objects.equals(password, that.password) &&
                Objects.equals(headPicture, that.headPicture);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, email, password, headPicture, del);
    }

}
